package java学习.第03章_流程控制语句;

import java.util.Scanner;

public class F_案例 {
    public static void main(String[] args) {
        求质数();
    }

    private static void 求质数() {
        System.out.println(Math.sqrt(123));
        long l = System.nanoTime();
        long l1 = System.currentTimeMillis();
        int k = 1;
        for (int i = 3; i < 100000; i += 2) {
            boolean b = true;
            for (int j = 3; j <= Math.sqrt(i); j+=2) {
                if (i % j == 0) {
                    b = false;
                    break;
                }
            }
            if (b) {
                k++;
            }
        }
        System.out.println(k);
        System.out.println(System.nanoTime() - l);
        System.out.println(System.currentTimeMillis() - l1);
    }

    private static void 嵌套循环() {
        //嵌套循环
        //9*9 乘法表
        for (int i = 1; i < 10; i++) {
            for (int j = 1; j <= i; j++) {
                System.out.print(i + "*" + j + "=" + i * j + "\t");
            }
            System.out.println();
        }
    }

    private static void 一种无限循环案例() {
        // 由于 break 可以跳出循环，
        // 所以可以做一个无限循环的条件，用break开跳出循环
        Scanner cin = new Scanner(System.in);
        while (true){
            int i = cin.nextInt();
            System.out.println(Integer.toHexString(i));
            if(i == 0){
                break;
            }
            if(true){
                continue;
            }
            System.out.println(2);
        }
        System.out.println("结束");
    }
}
